﻿@model StyleEditor

@section styles{
    @Styles.Render("~/Content/bootstrap-select.css")
}

@{
    string title = ViewBag.Title;
    string returnListUrl = ViewBag.ReturnListUrl;

    Product product = ViewBag.Product;
    List<PropertyType> propertyTypes = ViewBag.PropertyTypes;

    ViewBag.Title = "Chỉnh sửa " + title;
}

<section class="content-header">
    <h1>
        @title.ToUpper() <small>chỉnh sửa</small>
    </h1>
    <ol class="breadcrumb">
        <li>
            <a href="@Url.Action("Index", "Admin")">
                <i class="fa fa-home"></i> Trang chủ
            </a>
        </li>
        <li>
            <a href="@Url.Action("Index", "Product")">
                Danh sách sản phẩm
            </a>
        </li>
        <li>
            <a href="@Url.Action("Index", "Product", new { search = product.Code })">
                @product.Name - @product.Code
            </a>
        </li>
        <li>
            <a href="@Url.Action("Index", new { productId = product.Id })">
                Danh sách @title
            </a>
        </li>
        <li class="active">Chỉnh sửa</li>
    </ol>
</section>

<section class="content">
    @using (Html.BeginForm())
    {
        @Html.AntiForgeryToken()
        @Html.HiddenFor(m => m.Id)
        @Html.Hidden("ReturnListUrl", returnListUrl)

        <div class="row">
            <div class="col-md-6">
                <div class="box box-primary">
                    <div class="box-body">
                        <div class="row">
                            <div class="col-md-6">
                                @foreach (var propType in propertyTypes)
                                {                                   
                                    <div class="form-group">
                                        <label class="control-label">@propType.Name</label>
                                        @Html.DropDownList("Properties", ViewData[propType.NameId + "DDL"] as List<SelectListItem>, "Chọn " + propType.Name,
                                        new
                                        {
                                            @class = "selectpicker no-margin",
                                            data_width = "100%",
                                            data_size = "auto",
                                            data_live_search = "true"
                                        })
                                    </div>
                                }
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="control-label">Số lượng</label>
                                    @Html.TextBoxFor(m => m.Quantity, new { @class = "form-control" })
                                    @Html.ValidationMessageFor(m => m.Quantity)
                                </div>
                                <div class="form-group">
                                    <label class="control-label">Đơn giá</label>
                                    @Html.TextBoxFor(m => m.UnitPrice, new { @class = "form-control" })
                                    @Html.ValidationMessageFor(m => m.UnitPrice)
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="box-footer text-right">
                        <a href="@Request.UrlReferrer" class="btn btn-default pull-left">
                            <i class="fa fa-chevron-left"></i> Quay lại
                        </a>
                        <button type="reset" class="btn btn-warning">
                            <i class="fa fa-repeat"></i> Mặc định
                        </button>
                        <button type="submit" class="btn btn-success">
                            <i class="fa fa-check"></i> Xác nhận
                        </button>
                    </div>
                </div>
            </div>
        </div>
    }
</section>

@section scripts{
    @Scripts.Render("~/Scripts/bootstrap-select.js")
    <script>
        $('.selectpicker').selectpicker();

        ActiveMenu('product');
    </script>
}